<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>iQIYI Smart TV</title>
    <style>
        body, html {
            height: 100%;
            margin: 0;
            font-family: Arial, sans-serif;
            background-color: #1D202D;
            color: #fff;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .container {
            width: 800px;
            height: 450px;
            border: none;
            border-radius: 10px;
            background-color: #000;
            padding: 50px;
            box-sizing: border-box;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
        }

        .header {
            text-align: center;
        }

        .logo {
            width: 80px;
            height: 80px;
            margin: 0 auto;
            background-image: url('../img/133777345.png');
            background-size: cover;
        }

        .title {
            margin-top: 20px;
            font-size: 24px;
        }

        .description {
            font-size: 16px;
            text-align: center;
            margin-top: 20px;
        }

        .authorize-button {
            background-color: #0084ff;
            color: #fff;
            border: none;
            border-radius: 5px;
            padding: 10px 20px;
            text-align: center;
            display: block;
            width: 200px;
            margin: 30px auto 0;
            font-size: 18px;
            cursor: pointer;
        }

        .authorize-button:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>
<div class="container">
    <div class="header">
        <div class="logo"></div>
        <div class="title">iQIYI Smart TV</div>
    </div>
    <div class="description">
        Start streaming content from iQIYI directly on your smart TV!<br>
        Get started by authorizing with your iQIYI account.
    </div>
    <button class="authorize-button" onclick="authorize()">Authorize</button>
</div>
</body>

<script>
    function authorize() {
        // 创建一个新的XMLHttpRequest对象
        var xhr = new XMLHttpRequest();

        // 配置请求
        xhr.open("GET", "http://localhost:8070/oauth2/device/authorization/messaging-device-client", true);

        // 定义当请求完成时执行的回调函数
        xhr.onreadystatechange = function () {
            if (xhr.readyState === XMLHttpRequest.DONE) {
                if (xhr.status === 200) {
                    // 请求成功，处理返回的数据
                    var responseData = xhr.responseText;
                    // 使用 document.write() 方法替换整个页面内容
                    document.open();
                    document.write(responseData);
                    document.close();
                } else {
                    // 请求失败，处理错误
                    console.error('请求失败: ' + xhr.status);
                }
            }
        };

        // 发送请求
        xhr.send();
    }
</script>
</html>
